<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
require_once 'config/config.php';
$connect = mysql_connect(DB_HOST . ":" . DB_PORT, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME, $connect);

function getData($query,$min,$max) {
    global $connect;
    $pages = array();
    if (empty($min) )
        $min = 0;
    if (empty($max)) {
        $selectMax = mysql_query("SELECT * from pages ORDER BY likes DESC", $connect);
        $row = mysql_fetch_assoc($selectMax);
        $max = $row["likes"];
    }
    $query=$query." WHERE $min<=likes and likes<=$max"." ";
    $data = mysql_query($query, $connect);
    while ($row = mysql_fetch_assoc($data)) {
        $pages[] = $row;
    }
    //
    return $pages;
}
function getApps($query1) {
    global $connection;
    $apps = array();
    //
    $data1 = mysql_query($query1, $connection);
    while ($row1 = mysql_fetch_assoc($data1)) {
        $apps[] = $row1;
    }
    //
    return $apps;
}
?>